package com.example.pattern.adapter;

public class PhoneClient {

    public PhoneClient(TwoPlugIF twoPlug) {
        this.twoPlug = twoPlug;
    }

    //两孔插座
    private TwoPlugIF twoPlug;

    public TwoPlugIF getTwoPlug() {
        return twoPlug;
    }

    public void setTwoPlug(TwoPlugIF twoPlug) {
        this.twoPlug = twoPlug;
    }

    public void charge(){
        twoPlug.powerWithTwoPlug();
    }

    public static void main(String[] args) {

        //类适配器
        TwoPlugIF twoPlugIF = new ClazzAdapter();
        PhoneClient phoneClient = new PhoneClient(twoPlugIF);
        phoneClient.charge();

        System.out.println("===========================================");

        //对象适配器
        ThreePlug threePlug = new ThreePlug();
        TwoPlugIF twoPlugIF1 = new ObjectAdapter(threePlug);
        PhoneClient phoneClient2 = new PhoneClient(twoPlugIF1);
        phoneClient2.charge();


    }

}
